package List_;

import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

/**
 * 在List中放入若干整数，比如10个，然后删除其中的偶数。最后输出这个List
 */
@SuppressWarnings("all")
public class ListTest5 {
    public static void main(String[] args) {
        List linkedList = new LinkedList();
        for (int i = 0; i < 10; i++) {
            linkedList.add((int) (Math.random() * 10));
        }
        System.out.println(linkedList);
        Iterator iterator = linkedList.iterator();
        while (iterator.hasNext()) {
            if ((int) iterator.next() % 2 == 0) {
                iterator.remove();
            }
        }
        System.out.println(linkedList);


    }
}
